package com.yoomiito.app.present.cicle;

import com.yoomiito.app.Constant;
import com.yoomiito.app.model.cicle.CicleRecommendInfo;
import com.yoomiito.app.net.YmApi;
import com.yoomiito.app.ui.fragment.cicle.CircleGoodRecommendFragment;
import com.yoomiito.app.utils.NetworkUtils;
import com.yoomiito.app.utils.YMToast;

import cn.droidlover.xdroidmvp.mvp.XPresent;
import cn.droidlover.xdroidmvp.net.ApiException;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.XApi;

public class CicleGoodRecommendFmPresenter extends XPresent<CircleGoodRecommendFragment> {

    public void getGoodRecommentData(int page){
        if (NetworkUtils.checkNetPermission(getV().getContext())){
            getV().finishRefresh();
            return;
        }
        YmApi.getYmService()
                .geGoodsRecommendData(Constant.COMMUNITY_TYPE_GOODS_REMMOND,page,Constant.PAGE_SIZE)
                .compose(getV().bindToLifecycle())
                .compose(XApi.<CicleRecommendInfo>getApiTransformerData())
                .compose(XApi.<CicleRecommendInfo>getScheduler())
                .subscribe(new ApiSubscriber<CicleRecommendInfo>() {
                    @Override
                    public void onSuccess(CicleRecommendInfo data) {
//                        getV().setGoodRecommendData(data);
                    }

                    @Override
                    public void onFail(ApiException error) {
                        YMToast.showText("error");
                    }
                });
    }
}
